package me.kafeitu.demo.activiti.service.oa.announce;

import java.util.Date;

import me.kafeitu.demo.activiti.dao.AnnounceDao;
import me.kafeitu.demo.activiti.dao.LeaveDao;
import me.kafeitu.demo.activiti.entity.oa.Announce;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * 公告实体 
 * @author hpj
 *
 */
@Component
@Transactional(readOnly = true)
public class AnnounceManager {
	
	private AnnounceDao announceDao;

	public Announce getAnnounce(Long id) {
		return announceDao.findOne(id);
	}
	@Transactional(readOnly = false)
	public void saveAnnounce(Announce entity) {
		if (entity.getId() == null) {
            entity.setApplyTime(new Date());
        }
		announceDao.save(entity);
	}
	
	@Autowired
	public void setAnnounceDao(AnnounceDao announceDao) {
		this.announceDao = announceDao;
	}
	
}
